/**
 * Copyright 2008 Adam Ruggles.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package kiff.dao;

import java.util.List;

import kiff.exception.DataLayerException;


/**
 * An interface for the core DAO.  All DAO's wanting to have the core DAO functionality should implement this interface.
 * @author Adam
 * @version $Id: CoreDAO.java 66 2008-11-14 08:00:39Z a.ruggles $
 * @param <T> The Type of entity used as a return type and parameter type in Generic methods.
 */
public interface CoreDAO<T> {
    /**
     * Deletes a object of type T from the data layer.
     * @param object The object to delete.
     * @throws DataLayerException If an exception occurs in the data layer.
     */
    void delete(T object) throws DataLayerException;
    /**
     * Returns all objects of type T.
     * @return A list of all objects of type T.
     * @throws DataLayerException If an exception occurs in the data layer.
     */
    List<T> findAll() throws DataLayerException;
    /**
     * Returns an object of type T by it's identifier.
     * @param id The identifier for the object.
     * @return A object of type T.
     * @throws DataLayerException If an exception occurs in the data layer.
     */
    T findById(Object id) throws DataLayerException;
    /**
     * Inserts a new object of type T to the data layer.
     * @param object The object to insert.
     * @throws DataLayerException If an exception occurs in the data layer.
     */
    void insert(T object) throws DataLayerException;
    /**
     * Returns an object of type T by it's identifier.  An exception will be thrown if the object doesn't exist.
     * @param id The identifier for the object.
     * @return A object of type T.
     * @throws DataLayerException If an exception occurs in the data layer.
     */
    T loadById(Object id) throws DataLayerException;
    /**
     * Refresh the state of the instance from the database, overwriting changes made to the entity, if any.
     * @param object The object to refresh.
     * @throws DataLayerException If an exception occurs in the data layer.
     */
    void refresh(T object) throws DataLayerException;
    /**
     * Updates a object of type T to the data layer.
     * @param object The object to update.
     * @return The persisted instance of the entity object.
     * @throws DataLayerException If an exception occurs in the data layer.
     */
    T update(T object) throws DataLayerException;
}
